package com.zlfund.cat.zjgsmk.ui.channel;

import com.zlfund.cat.zjgsmk.api.ZjgsmkService;
import com.zlfund.cat.zjgsmk.bean.SocialBean;
import com.zlfund.cat.zjgsmk.net.INetCallback;
import com.zlfund.cat.zjgsmk.net.RetrofitQueryMapRequest;
import com.zlfund.cat.zjgsmk.ui.user.UserManager;

import java.net.URLEncoder;

/**
 * @author chenj
 * @date 2017/9/22
 * @use ${}
 */

public class NetUtil {

    public static void getChannelData(int page, String is, String channelId, INetCallback<SocialBean> callback){
        RetrofitQueryMapRequest<SocialBean> request = new RetrofitQueryMapRequest<>();
        String auth = UserManager.getAuth();
        request.addParams("page", String.valueOf(page))
                .addParams("is", is)
                .addParams("key", channelId)
                .addParams("auth", auth);
        request.build(ZjgsmkService.ChannelDetailService.class)
                .enqueueWithRx("getChannelData", callback);
    }

    public static String toURLEncoded(String paramString) {
        if (paramString == null || paramString.equals("")) {
            return "";
        }

        try {
            String str = new String(paramString.getBytes(), "UTF-8");
            str = URLEncoder.encode(str, "UTF-8");
            return str;
        }
        catch (Exception localException) {
        }

        return "";
    }
}
